package com.noble.meether.fragment.rob.util;

import android.view.View;

import java.util.Calendar;

/**
 * 女性抢聊点击监听，延长点击间隔，防止快速点击
 */
public abstract class RobClickListener implements View.OnClickListener {

    // 连续两次点击之间的时间间隔
    private static int MIN_CLICK_DELAY_TIME = 5000;

    // 上一次的点击时间
    private long lastClickTime = 0;

    public RobClickListener() {
    }

    public RobClickListener(int interval) {
        MIN_CLICK_DELAY_TIME = interval;
    }

    @Override
    public void onClick(View v) {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        if (currentTime - lastClickTime > MIN_CLICK_DELAY_TIME) {
            lastClickTime = currentTime;
            onRobClick(v);
        }
    }

    public abstract void onRobClick(View v);
}